
import UpmsBasicApi from '@/api/upms/basic'
import { numberAdd, numberSub, numberMul, numberDiv } from '@/utils/math'

export const VxeSysDataMixin = {
  data() {
    return {
      dictData: {
      }
    }
  },
  computed: {

  },
  mounted() {

  },
  methods: {
    doMath(type, ...args) {
      if (type === 'numberAdd') {
        return numberAdd(...args)
      } else if (type === 'numberSub') {
        return numberSub(...args)
      } else if (type === 'numberMul') {
        return numberMul(...args)
      } else if (type === 'numberDiv') {
        return numberDiv(...args)
      }
    },
    getObjById(dataList, id, idField = 'id') {
      const current = dataList.find(row => row[idField] === id)
      return current || {}
    },

    isHistoryMonth(date) {
      const currentMonthFirstDay = this.$moment().format('YYYY-MM') + '-01'
      return currentMonthFirstDay > date
    },
    async genBillNo(prefix, modelValue, field) {
      const res = await UpmsBasicApi.genBillNo(prefix)
      modelValue[field] = res.data
    }
  }
}

